from frappe.query_builder.custom import GROUP_CONCAT, MATCH, STRING_AGG, TO_TSVECTOR
from frappe_dm.query_builder.custom import DM_GROUP_CONCAT, DM_MATCH
from frappe_dm.query_builder.utils import db_type_is
from frappe.query_builder.utils import ImportMapper

# 更新 GroupConcat 和 Match 函数的映射
GroupConcat = ImportMapper({
    db_type_is.MARIADB: GROUP_CONCAT, 
    db_type_is.POSTGRES: STRING_AGG,
    db_type_is.DM: DM_GROUP_CONCAT
})

Match = ImportMapper({
    db_type_is.MARIADB: MATCH, 
    db_type_is.POSTGRES: TO_TSVECTOR,
    db_type_is.DM: DM_MATCH
})
